package com.eastfair.projectcore.service.impl;

import com.eastfair.core.snowflake.DefaultUidGenerator;
import com.eastfair.projectcore.dao.DictTypeMapper;
import com.eastfair.projectcore.entity.DictType;
import com.eastfair.projectcore.service.DictTypeService;
import com.eastfair.boot.service.SuperCacheServiceImpl;
import com.eastfair.cache.projectcore.DictCacheKeyBuilder;
import com.eastfair.core.base.R;
import com.eastfair.core.model.CacheKeyBuilder;
import com.eastfair.uid.model.SelfUidDto;
import com.eastfair.uid.service.SelfUidService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 业务实现类
 *
 * </p>
 *
 * @author zjn
 * @date 2021-07-26
 */
@Slf4j
@Service
public class DictTypeServiceImpl extends SuperCacheServiceImpl<DictTypeMapper, DictType> implements DictTypeService {

//    @Autowired
//    SelfUidService selfUidService;

    @Override
    protected CacheKeyBuilder cacheKeyBuilder() {
        return new DictCacheKeyBuilder();
    }

    /**
     * 处理新增相关处理
     *
     * @param model 实体
     * @return 是否成功
     */
    @Override
    protected R<Boolean> handlerSave(DictType model) {
        //雪花ID,不需要分库分表
//        SelfUidDto selfUidDto = new SelfUidDto();
//        selfUidDto.setDbSuffix(0);
//        selfUidDto.setTableSuffix(0);
//        model.setId(selfUidService.getUid(selfUidDto));
        model.setId(DefaultUidGenerator.getUid(0L));
        return R.successDef();
    }

}
